<script>
// 删除任务弹窗
import { reqAutoDel } from '@/api'
import { defineComponent } from 'vue'
export default defineComponent({
	name: 'deleteTask'
})
</script>
<script setup>
import { toRaw } from '@vue/reactivity'
import { ref, defineExpose } from 'vue'
const dialogVisible = ref(false)
const form = ref({})
const show = (val) => {
	dialogVisible.value = true
	form.value = toRaw(val)
}
const handleClose = (done) => {
	dialogVisible.value = false
}
const onSubmit = async () => {
	const r = reqAutoDel({
		id: form.value.id
	})
	if (r) {
		ElMessage.success('删除成功')
		dialogVisible.value = false
		emits('diaUpdate')
	}
}
defineExpose({
	show
})
const emits = defineEmits(['diaUpdate'])
</script>
<template>
	<el-dialog v-model="dialogVisible" title="删除分组" width="30%" :before-close="handleClose">
		<div>是否确认删除「{{ form.name }}」任务？</div>
		<template #footer>
			<span class="dialog-footer">
				<el-button @click="dialogVisible = false">取消</el-button>
				<el-button type="primary" @click="onSubmit">保存</el-button>
			</span>
		</template>
	</el-dialog>
</template>
<style scoped>
.dialog-footer button:first-child {
	margin-right: 10px;
}
</style>
